home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / CursorDevices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-29  |  7.7 KB  |  216 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CursorDevices.h
  3.  
  4.      Contains:    Cursor Devices (mouse/trackball/etc) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.3
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CURSORDEVICES__
  21. #define __CURSORDEVICES__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MIXEDMODE__
  30. #include <MixedMode.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_ALIGN_SUPPORTED
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT_SUPPORTED
  42. #pragma import on
  43. #endif
  44.  
  45. /*
  46.                        * * *  W A R N I N G  * * * 
  47.  
  48.     On currently shipping PowerMacs, the CursorDevices manager is implemented
  49.     in 68K code and emulated.  Unfortunately, the MixedMode glue in InterfaceLib
  50.     is incorrect.  It and the 1.0 version of this file had incorrect parameter
  51.     lists for most functions.
  52.     
  53.     As a first step to avoid runtime errors, the functions in this file were 
  54.     renamed (e.g. from"CrsrDevButtons" to "CursorDeviceButtons").  This will result
  55.     in a link time error if a PowerPC application tries to call the functions.
  56.     When InterfaceLib is fixed, the new names will be exported and PowerPC
  57.     code will then be able to call them.
  58.     
  59. */
  60. typedef short ButtonOpcode;
  61.  
  62. /* ButtonOpcodes */
  63.  
  64. enum {
  65.     kButtonNoOp                    = 0,                            /* No action for this button */
  66.     kButtonSingleClick            = 1,                            /* Normal mouse button */
  67.     kButtonDoubleClick            = 2,                            /* Click-release-click when pressed */
  68.     kButtonClickLock            = 3,                            /* Click on press, release on next press */
  69.     kButtonCustom                = 6                                /* Custom behavior, data = CursorDeviceCustomButtonUPP */
  70. };
  71.  
  72. /* Device Classes */
  73. enum {
  74.     kDeviceClassAbsolute        = 0,                            /* a flat-response device */
  75.     kDeviceClassMouse            = 1,                            /* mechanical or optical mouse */
  76.     kDeviceClassTrackball        = 2,                            /* trackball */
  77.     kDeviceClassTrackPad        = 3,
  78.     kDeviceClass3D                = 6                                /* a 3D pointing device */
  79. };
  80.  
  81. /* Structures used in Cursor Device Manager calls */
  82. struct CursorData {
  83.     struct CursorData                *nextCursorData;            /* next in global list */
  84.     Ptr                                displayInfo;                /* unused (reserved for future) */
  85.     Fixed                            whereX;                        /* horizontal position */
  86.     Fixed                            whereY;                        /* vertical position */
  87.     Point                            where;                        /* the pixel position */
  88.     Boolean                            isAbs;                        /* has been stuffed with absolute coords */
  89.     UInt8                            buttonCount;                /* number of buttons currently pressed */
  90.     unsigned short                    screenRes;                    /* pixels per inch on the current display */
  91.     short                            privateFields[22];            /* fields use internally by CDM */
  92. };
  93. typedef struct CursorData CursorData, *CursorDataPtr;
  94.  
  95. struct CursorDevice {
  96.     struct CursorDevice                *nextCursorDevice;            /* pointer to next record in linked list */
  97.     CursorData                        *whichCursor;                /* pointer to data for target cursor */
  98.     long                            refCon;                        /* application-defined */
  99.     long                            unused;                        /* reserved for future */
  100.     OSType                            devID;                        /* device identifier (from ADB reg 1) */
  101.     Fixed                            resolution;                    /* units/inch (orig. from ADB reg 1) */
  102.     UInt8                            devClass;                    /* device class (from ADB reg 1) */
  103.     UInt8                            cntButtons;                    /* number of buttons (from ADB reg 1) */
  104.     UInt8                            filler1;                    /* reserved for future */
  105.     UInt8                            buttons;                    /* state of all buttons */
  106.     UInt8                            buttonOp[8];                /* action performed per button */
  107.     unsigned long                    buttonTicks[8];                /* ticks when button last went up (for debounce) */
  108.     long                            buttonData[8];                /* data for the button operation */
  109.     unsigned long                    doubleClickTime;            /* device-specific double click speed */
  110.     Fixed                            acceleration;                /* current acceleration */
  111.     short                            privateFields[15];            /* fields used internally to CDM */
  112. };
  113. typedef struct CursorDevice CursorDevice, *CursorDevicePtr;
  114.  
  115. /* for use with CursorDeviceButtonOp when opcode = kButtonCustom */
  116. /*
  117.         CursorDeviceCustomButtonProcPtr uses register based parameters on the 68k and cannot
  118.         be written in or called from a high-level language without the help of
  119.         mixed mode or assembly glue.
  120.  
  121.             typedef pascal void (*CursorDeviceCustomButtonProcPtr)(CursorDevicePtr ourDevice, short button);
  122.  
  123.         In:
  124.          => ourDevice       A2.L
  125.          => button          D3.W
  126. */
  127.  
  128. #if GENERATINGCFM
  129. typedef UniversalProcPtr CursorDeviceCustomButtonUPP;
  130. #else
  131. typedef Register68kProcPtr CursorDeviceCustomButtonUPP;
  132. #endif
  133.  
  134. enum {
  135.     uppCursorDeviceCustomButtonProcInfo = kRegisterBased
  136.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA2, SIZE_CODE(sizeof(CursorDevicePtr)))
  137.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterD3, SIZE_CODE(sizeof(short)))
  138. };
  139.  
  140. #if GENERATINGCFM
  141. #define NewCursorDeviceCustomButtonProc(userRoutine)        \
  142.         (CursorDeviceCustomButtonUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, GetCurrentArchitecture())
  143. #else
  144. #define NewCursorDeviceCustomButtonProc(userRoutine)        \
  145.         ((CursorDeviceCustomButtonUPP) (userRoutine))
  146. #endif
  147.  
  148. #if GENERATINGCFM
  149. #define CallCursorDeviceCustomButtonProc(userRoutine, ourDevice, button)        \
  150.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, (ourDevice), (button))
  151. #else
  152. /* (*CursorDeviceCustomButtonProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  153. #endif
  154.  
  155. extern pascal OSErr CursorDeviceMove(CursorDevicePtr ourDevice, long deltaX, long deltaY)
  156.  TWOWORDINLINE(0x7000, 0xAADB);
  157. extern pascal OSErr CursorDeviceMoveTo(CursorDevicePtr ourDevice, long absX, long absY)
  158.  TWOWORDINLINE(0x7001, 0xAADB);
  159. extern pascal OSErr CursorDeviceFlush(CursorDevicePtr ourDevice)
  160.  TWOWORDINLINE(0x7002, 0xAADB);
  161. extern pascal OSErr CursorDeviceButtons(CursorDevicePtr ourDevice, short buttons)
  162.  TWOWORDINLINE(0x7003, 0xAADB);
  163. extern pascal OSErr CursorDeviceButtonDown(CursorDevicePtr ourDevice)
  164.  TWOWORDINLINE(0x7004, 0xAADB);
  165. extern pascal OSErr CursorDeviceButtonUp(CursorDevicePtr ourDevice)
  166.  TWOWORDINLINE(0x7005, 0xAADB);
  167. extern pascal OSErr CursorDeviceButtonOp(CursorDevicePtr ourDevice, short buttonNumber, ButtonOpcode opcode, long data)
  168.  TWOWORDINLINE(0x7006, 0xAADB);
  169. extern pascal OSErr CursorDeviceSetButtons(CursorDevicePtr ourDevice, short numberOfButtons)
  170.  TWOWORDINLINE(0x7007, 0xAADB);
  171. extern pascal OSErr CursorDeviceSetAcceleration(CursorDevicePtr ourDevice, Fixed acceleration)
  172.  TWOWORDINLINE(0x7008, 0xAADB);
  173. extern pascal OSErr CursorDeviceDoubleTime(CursorDevicePtr ourDevice, long durationTicks)
  174.  TWOWORDINLINE(0x7009, 0xAADB);
  175. extern pascal OSErr CursorDeviceUnitsPerInch(CursorDevicePtr ourDevice, Fixed resolution)
  176.  TWOWORDINLINE(0x700A, 0xAADB);
  177. extern pascal OSErr CursorDeviceNextDevice(CursorDevicePtr *ourDevice)
  178.  TWOWORDINLINE(0x700B, 0xAADB);
  179. extern pascal OSErr CursorDeviceNewDevice(CursorDevicePtr *ourDevice)
  180.  TWOWORDINLINE(0x700C, 0xAADB);
  181. extern pascal OSErr CursorDeviceDisposeDevice(CursorDevicePtr ourDevice)
  182.  TWOWORDINLINE(0x700D, 0xAADB);
  183.  
  184.  
  185. /*
  186.                        * * *  W A R N I N G  * * * 
  187.                 
  188.     Even though the glue in InterfaceLib on PowerMacs for CursorDevices
  189.     is generally wrong, the two popular routines CrsrDevNextDevice
  190.     and CrsrDevMoveTo actually work.  Because we still don't have a 
  191.     fixed library, we are adding back prototypes (with the old name)
  192.     so that these functions can be called.
  193.  
  194.  
  195. */
  196. pascal OSErr CrsrDevMoveTo(CursorDevicePtr ourDevice, long absX, long absY)
  197.  TWOWORDINLINE(0x7001, 0xAADB);
  198.  
  199. pascal OSErr CrsrDevNextDevice(CursorDevicePtr *ourDevice)
  200.  TWOWORDINLINE(0x700B, 0xAADB);
  201.  
  202.  
  203. #if PRAGMA_IMPORT_SUPPORTED
  204. #pragma import off
  205. #endif
  206.  
  207. #if PRAGMA_ALIGN_SUPPORTED
  208. #pragma options align=reset
  209. #endif
  210.  
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214.  
  215. #endif /* __CURSORDEVICES__ */
  216.